#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MX = 1e6 + 5;

int n, m;
int np[MX], cnt[MX], ans[MX];
vector<int> primes;
void init(int n) {
  np[1] = 1, cnt[1] = 0;
  rep(i, 2, n) {
    if (!np[i]) {
      primes.push_back(i);
      cnt[i] = 1;
    }
    for (int j : primes) {
      ll k = 1ll * j * i;
      if (k > n) break;
      np[k] = 1;
      cnt[k] = i % j == 0 ? cnt[i] : cnt[i] + 1;
      if (i % j == 0) break;
    }
  }
  rep(i, 1, n) {
    if (cnt[i] == 2)
      ans[i] = i;
    else
      ans[i] = ans[i - 1];
  }
}
ll sqrt2(ll n) {
  ll x = sqrt(n);
  if (x * x > n) x--;
  if ((x + 1) * (x + 1) <= n) x++;
  return x;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  init(1000000);
  int t;
  cin >> t;
  while (t--) {
    ll x;
    cin >> x;
    ll y = ans[sqrt2(x)];
    y = y * y;
    cout << y << endl;
  }
  return 0;
}